<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>readline</title>
</head>
<body>
<script>
    var str="sdffxdfv";
    var num=5;
    function word(n,str){
        var s="";
        if(str.length<n){
            return str;
        }else{
            s=str[0]+(str.length-2)+str[str.length-1];
            return s;
        }
    }
    var s=word(num,str);
   console.log(s);
</script>
</body>
</html>